local CommonOHOH = _G.CommonOHOH;
local M = CommonOHOH.class.new(script, CommonOHOH.files.BaseComponent());
local Client_AudioManager = _G.ClientOHOH.load.Client_AudioManager();

local broGui=_G.ClientOHOH.load.UIManager().ui_list.BroGui

--概述：控制怪物的动画播放

----------
function M.new(self,...)
	return M(self,...);
end;

function M.ctor(self, parent)
	M.super.ctor(self, parent);

    self.player=self.parent.player
	self.character=self.parent




	self.character:GetState("upgrade").EnterEvent:Connect(function()

        self:AddProcess(function()
            self:Wait(1)
            self:Attack()
        end)

	end)

    self.character:GetState("changeWeapon").EnterEvent:Connect(function()
        task.wait()
        self:Attack()
	end)

    self.character:GetState("equip").EnterEvent:Connect(function()
        task.wait()
        self:Attack()
	end)

    self.character:GetShowState("show").EnterEvent:Connect(function()
        self:AddProcess(function()
            self:Wait(1)
            self:Attack()
        end)
    end)

end;

--析构函数
function M.dtor(self)
    M.super.dtor(self);
end;

local BowClass=require(script.Parent.Parent.BroBow)

function M.CreateNewWeapon(self,equipId)
    self.Weapon=BowClass.new(equipId,self.character,self.player)

end


function M.Attack(self)
    if self.Weapon then
        self.Weapon:StartAttack()
    end
end

function M.SetWeapon(self,equipId)

    if not self.Weapon then
        self:CreateNewWeapon(equipId)
        return 
    end

    if self.Weapon:GetEquipId()==equipId then
        return 
    end

    self.Weapon:dtor()
    self.Weapon=nil
    self:CreateNewWeapon(equipId)
end



return M